package net.ermannofranco.xmltest;

/*
 * PiattaformaScolastica_schema.java
 *
 * Created on 28 marzo 2004, 20.02
 */
import static net.ermannofranco.xml.schema.Use.OPTIONAL;
import static net.ermannofranco.xml.schema.Use.REQUIRED;
import static net.ermannofranco.xml.schema.XmlType.BOOLEAN;
import static net.ermannofranco.xml.schema.XmlType.NMTOKEN;
import static net.ermannofranco.xml.schema.XmlType.POS_INTEGER;
import static net.ermannofranco.xml.schema.XmlType.STRING;
import net.ermannofranco.xml.schema.ComplexType;
import net.ermannofranco.xml.schema.ExtensionSimple;
import net.ermannofranco.xml.schema.Schema;
import net.ermannofranco.xml.schema.Sequence;

public class Videoteca_schema extends Schema {

	public Videoteca_schema() {

		// Il documento Schema estende un Documento xml, quindi anche in questo
		// caso � l'unico istanziabile.
		setElemFormDefQualified(true)// metodo di Schema
				.setTargetNamespace("eee", "abcde.cow");

		ComplexType attore;
		ComplexType musiche;
		ComplexType video;
		ExtensionSimple ex;
		Sequence seq;

		(attore = addComplexType("attore")).addDocumentation("attore del film");
		ex = attore.setSimpleContent().setExtension(STRING);
		ex.addTagAttribute("principale", BOOLEAN).setUse(OPTIONAL);
		ex.addTagAttribute("nome", STRING).setUse(REQUIRED);

		(musiche = addComplexType("musiche"))
				.addDocumentation("musiche del film");
		ex = musiche.setSimpleContent().setExtension(STRING);
		ex.addTagAttribute("originali", BOOLEAN).setUse(OPTIONAL);
		ex.addTagAttribute("autore", STRING).setUse(OPTIONAL);

		video = addComplexType("video");
		seq = video.setSequence();
		seq.addElem("trama").setType(STRING).setMaxOccurs(1).setMinOccurs(1);
		seq.addElem("attore").setType(attore).setUnboundedMaxOccurs()
				.setMinOccurs(1);
		seq.addElem("musiche").setType(musiche).setMaxOccurs(1).setMinOccurs(1);

		// metodi raccolti, piu' comodo
		video.addTagAttribute("codice", NMTOKEN, REQUIRED);
		video.addTagAttribute("regista", STRING, REQUIRED);
		video.addTagAttribute("titolo", STRING, REQUIRED);

		video.addTagAttribute("copie", POS_INTEGER, REQUIRED);
		video.addTagAttribute("disponibili", POS_INTEGER, REQUIRED);
		video.addTagAttribute("supporto", STRING, REQUIRED);
		video.addTagAttribute("genere", STRING, REQUIRED);
		video.addTagAttribute("locandina", STRING, OPTIONAL);

		addElem("videoteca").setComplexType().setSequence().addElem("video",
				video).setMinOccurs(1).setUnboundedMaxOccurs();

		// save("../generati/"+getClass().getName());// questo salva...

	}

}
